package tgc.edu.tms.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.springframework.data.annotation.CreatedBy;

import com.fasterxml.jackson.annotation.JsonIgnore;

import tgc.edu.tms.custom.BaseEntity;

//哪些教室
@Entity
public class Classroom extends BaseEntity<Integer> {
	private Location location;   //所属位置
	private String floor;   //教室所在楼层
	private String serialNumber;   //编号s8_602
	private Integer capacity;    //容量（一个教室能做多少人）
	private ClassType type;    //类型（调停课是学校内还是外企内）
	@JsonIgnore
	private List<ClassSchedule> schedule=new ArrayList<>();//对应生成的课程表 ClassSchedule表
	@Column(nullable=false)
	public String getFloor() {
		return floor;
	}
	public void setFloor(String floor) {
		this.floor = floor;
	}
	@Column(unique=true,nullable=false)
	public String getSerialNumber() {
		return serialNumber;
	}
	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}
	@Column(nullable=false)
	public Integer getCapacity() {
		return capacity;
	}
	public void setCapacity(Integer capacity) {
		this.capacity = capacity;
	}
	@ManyToOne
	@CreatedBy
	public ClassType getType() {
		return type;
	}
	public void setType(ClassType type) {
		this.type = type;
	}
	@ManyToOne
	@CreatedBy
	public Location getLocation() {
		return location;
	}
	public void setLocation(Location location) {
		this.location = location;
	}
	@OneToMany(mappedBy="classroom",cascade=CascadeType.ALL)
	@Column(nullable=false)
	public List<ClassSchedule> getSchedule() {
		return schedule;
	}
	public void setSchedule(List<ClassSchedule> schedule) {
		this.schedule = schedule;
	}
/*	@Transient
	public String getName(){
		return location==null?null:location.getName();

	}*/
}
